<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${blog.title}">博客详情</title>
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="../static/css/typo.css">
    <link rel="stylesheet" href="../static/lib/prism/prism.css">
    <link rel="stylesheet" href="../static/lib/tocbot/tocbot.css">
    <link rel="stylesheet" type="text/css" href="../static/css/myStyle.css">
</head>
<body>
    <!--导航-->
    <nav id="nav" th:replace="_fragments :: menu(0)" class="ui inverted attached m-padded-tb-mini">
        <div class="ui container">
            <div class="ui inverted secondary stackable menu">
                <h2 class="ui olive header item" style="font-family: STSong">LENSTAR</h2>
                <!--<div class="right m-item item m-mobile-hide">-->
                <a href="./index.html" class="m-item item m-mobile-hide"><i class="home icon"></i>首页</a>
                <a href="types.html" class="m-item item m-mobile-hide"><i class="clone outline icon"></i>分类</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="tags icon"></i>标签</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="info icon"></i>关于我</a>
                <!--</div>-->
                <div class="m-item right item m-mobile-hide">
                    <form name="search" action="/search" method="post" target="_blank">
                        <div class="ui icon transparent inverted input">
                            <input type="text" name="query" placeholder="Search...." value="">
                            <i class="search link icon"></i>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <a href="#" class="ui menu toggle button m-right-top m-mobile-show" style="background-color: rgba(0,0,0,0); color: gainsboro">
            <i class="sidebar icon"></i>
        </a>
    </nav>
    <!--顶部图片-->
    <div class="m-bg-type_outer" style="width: 100%;height: 50%">
        <img src="" th:src="@{${blog.firstPicture}}" alt="" class="ui m-bg image" style="width: 100%;height: 100%">
        <div class="m-bg-class_cover">
            <div class="ui container" style="position: relative ;bottom: -540px;">
                <h2 class="m-font-size-title-large" align="center" th:text="${blog.title}">Markdown编辑</h2>
                <div class="ui container" align="center">
                    <div class="ui horizontal link list" align="center">
                        <div class="item">
                            <div class="ui orange basic label" style="font-size: 7px" th:text="${blog.flag}">原创</div>
                        </div>
                        <div class="item">
                            <!--<i class="user outline outline icon m-font-size-text-mini"></i>-->
                            <img src="../static/images/avatar.jpg" th:src="${blog.avatar}" alt="" class="ui avatar image">
                            <a href="#" style="color: #ffffff;font-size: 15px" th:text="${blog.nickname}">LENSTAR</a>
                        </div>
                        <div class="item">
                            <i class="calendar icon m-font-size-text-mini"></i>
                            <span th:text="${#dates.format(blog.createTime,'yyyy-MM-dd')}" class="m-font-size-text-mini">2020-01-01</span>
                        </div>
                        <div class="item">
                            <i class="clone icon m-font-size-text-mini"></i>
                            <a href="#" target="_blank" style="color: #ffffff;font-size: 16px" th:text="${blog.typeName}">我的故事</a>
                        </div>
                        <div class="item">
                            <i class="eye icon m-font-size-text-mini"></i> <span th:text="${blog.views}" class="m-font-size-text-mini">2222</span>
                        </div>
                        <div class="item">
                            <i class="comment outline icon m-font-size-text-mini"></i>
                            <span th:text="${blog.commentCount}" class="m-font-size-text-mini">2222</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--中间内容-->
    <div id="container" class="m-padded-tb-large m-margin--">
        <div class="ui container m-opacity">
            <div class="ui stackable grid">
                <!--左边博客详情-->
                <div class="eleven wide column">
                    <!--头部-->
                    <!--<div class="ui top attached segment">-->
                        <!--<div class="ui horizontal link list">-->
                            <!--<div class="item">-->
                                <!--<img src="../static/images/avatar.jpg" th:src="${blog.avatar}" alt="" class="ui avatar image">-->
                                <!--<div class="content"><a href="" th:href="@{/about}" class="header">LENSTAR</a></div>-->
                            <!--</div>-->
                            <!--<div class="item">-->
                                <!--<i class="calendar icon"></i> <span th:text="${#dates.format(blog.createTime,'yyyy-MM-dd')}">2020-07-20</span>-->
                            <!--</div>-->
                            <!--<div class="item">-->
                                <!--<i class="eye icon"></i> <span th:text="${blog.views}">123</span>-->
                            <!--</div>-->
                            <!--<div class="item">-->
                                <!--<i class="comment outline icon"></i> <span th:text="${blog.commentCount}">8</span>-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--内容-->
                    <div class="ui attached padded segment">
                        <div class="ui right aligned basic segment" style="background-color: rgba(255, 255, 255, 0) !important;">
                            <div class="ui orange basic label" style="background-color: rgba(255,255,255,0) !important;" th:utext="${blog.flag}">原创</div>
                        </div>
                        <h2 class="ui center aligned header" th:text="${blog.title}">博客标题</h2>

                        <div id="content" class="js-toc-content typo typo-selection m-padded-lr-responsive m-padded-tb-large" th:utext="${blog.content}">

                        </div>

                        <!--分类-->
                        <div class="m-padded-lr">
                            <div class="ui basic teal left pointing label" th:text="${blog.typeName}">
                                方法论
                            </div>
                        </div>

                        <!--赞赏-->
                        <div class="ui center aligned basic segment" style="background-color: #FFF0 !important;">
                            <button id="payButton" class="ui orange basic circular button">赞赏</button>
                        </div>
                        <div class="ui payRQ flowing popup transition hidden">
                            <div class="ui orange basic label">
                                <div class="ui images" style="font-size: inherit !important;">
                                    <div class="image">
                                        <img src="../static/images/wechatpay.jpg" th:src="@{/images/wechatpay.jpg}" alt="" class="ui rounded bordered image" style="width: 120px; height: 120px;">
                                        <div>微信</div>
                                    </div>
                                    <div class="image">
                                        <img src="../static/images/zhifupay.jpg" th:src="@{/images/zhifupay.jpg}" alt="" class="ui rounded bordered image" style="width: 120px; height: 120px;">
                                        <div>支付宝</div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        
                    </div>
                    <!--博客信息-->
                    <div class="ui attached positive message">
                        <div class="ui middle aligned grid">
                            <div class="eleven wide column">
                                <ul class="list">
                                    <li>作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;者：<span th:text="${blog.nickname}" style="font-family: STSong">LENSTAR</span> <a href="#" th:href="@{/about}">(联系作者)</a> </li>
                                    <li>发表时间：<span th:text="${#dates.format(blog.createTime,'yyyy-MM-dd HH:mm')}">2020-07-20</span></li>
                                    <li>版权声明：自由转载</li>
                                </ul>
                            </div>
                            <div class="five wide column">
                                <img src="../static/images/wechat.jpg" th:src="@{/images/wechat.jpg}" alt="" class="ui right floated rounded bordered image" style="width: 110px;">
                            </div>
                        </div>
                    </div>

                    <!--留言区域-->
                    <div class="ui bottom attached segment">
                        <div id="comment-container" class="ui teal segment">
                            <div th:fragment="commentList">
                                <div class="ui comments" style="max-width: 100%">
                                    <h3 class="ui dividing header">评论</h3>
                                    <div class="comment" th:each="comment : ${comments}">
                                        <a class="avatar">
                                            <img src="../static/images/avatar.jpg" th:src="@{${comment.avatar}}">
                                        </a>
                                        <div class="content">
                                            <a class="author">
                                                <span th:text="${comment.nickname}">Matt</span>
                                                <div class="ui mini basic teal left pointing label m-padded-mini" th:if="${comment.adminComment}">博主</div>
                                            </a>
                                            <div class="metadata">
                                                <span class="date" th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                            </div>
                                            <div class="text" th:text="${comment.content}">
                                                How artistic!
                                            </div>
                                            <div class="actions">
                                                <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}" onclick="reply(this)">回复</a>
                                                <a class="delete" href="#" th:href="@{/comment/{param1}/{param2}/delete(param1=${comment.blogId},param2=${comment.id})}" onclick="return confirm('确定要删除该评论吗？三思啊! 删了可就没了！')" th:if="${session.user}">删除</a>
                                            </div>
                                        </div>
                                        <!--子集评论-->
                                        <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">
                                            <div class="comment" th:each="reply : ${comment.replyComments}">
                                                <a class="avatar">
                                                    <img src="https://unsplash.it/100/100?image=1005" th:src="@{${reply.avatar}}">
                                                </a>
                                                <div class="content">
                                                    <a class="author" >
                                                        <span th:text="${reply.nickname}">小红</span>
                                                        <div class="ui mini basic teal left pointing label m-padded-mini" th:if="${reply.adminComment}">博主</div>
                                                        &nbsp;<span th:text="|@ ${reply.parentNickname}|" class="m-teal">@ 小白</span>
                                                    </a>
                                                    <div class="metadata">
                                                        <span class="date" th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                                    </div>
                                                    <div class="text" th:text="${reply.content}">
                                                        How artistic!
                                                    </div>
                                                    <div class="actions">
                                                        <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${reply.id},data-commentnickname=${reply.nickname}" onclick="reply(this)">回复</a>
                                                        <a class="delete" href="#" th:href="@{/comment/{param1}/{param2}/delete(param1=${reply.blogId},param2=${reply.id})}" onclick="return confirm('确定要删除该评论吗？三思啊! 删了可就没了！')" th:if="${session.user}">删除</a>
                                                        <!--<a class="delete" href="#" th:href="@{/comment/{id}/delete(id=${reply.id})}" onclick="return confirm('确定要删除该评论吗？三思啊! 删了可就没了！')" th:if="${session.user}">删除</a>-->

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div id="comment-form" class="ui form">
                            <!--博客id-->
                            <input type="hidden" name="blogId" th:value="${blog.id}">
                            <!--父评论id-->
                            <input type="hidden" name="parentComment.id" value="-1">
                            <div class="field">
                                <textarea name="content" placeholder="添加评论..."></textarea>
                            </div>
                            <div class="fields">
                                <div class="field m-mobile-wide m-margin-bottom-small">
                                    <div class="ui left icon input">
                                        <i class="user icon"></i>
                                        <input type="text" name="nickname" placeholder="姓名" th:value="${session.user}!=null ? ${session.user.nickname}">
                                    </div>
                                </div>
                                <div class="field m-mobile-wide m-margin-bottom-small">
                                    <div class="ui left icon input">
                                        <i class="mail icon"></i>
                                        <input type="text" name="email" placeholder="邮箱"  th:value="${session.user}!=null ? ${session.user.email}">
                                    </div>
                                </div>
                                <div class="field m-mobile-wide m-margin-bottom-small">
                                    <button id="commentpost-btn" type="button" class="ui teal button"><i class="edit icon"></i> 发布</button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

                <!--右边的top-->
                <div class="five wide column">
                    <!--分类-->
                    <div class="ui segments">
                        <div class="ui secondary segment">
                            <div class="ui two column grid">
                                <div class="column">
                                    <i class="clone outline icon"></i> 分类
                                </div>
                                <div class="right aligned column">
                                    <a href="" th:href="@{/types/-1}">更多 <i class="angle double down icon"></i></a>
                                </div>
                            </div>
                            <div class="ui teal segment" style="background-color: rgba(255, 255, 255, 0) !important;">
                                <div class="ui fluid vertical menu" style="background-color: rgba(255, 255, 255, 0) !important;">
                                    <a href="" th:href="@{/types/{id}(id=${type.id})}" class="item" th:each="type : ${types}">
                                        <span th:text="${type.name}">学习日志</span>
                                        <div class="ui teal basic left pointing label" th:text="${#arrays.length(type.blogList)}">13</div>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--标签-->
                    <div class="ui segments m-margin-tb-big">
                        <div class="ui secondary segment">
                            <div class="ui two column grid">
                                <div class="column">
                                    <i class="tags icon"></i> 标签
                                </div>
                                <div class="right aligned column">
                                    <a href="" th:href="@{/tags/-1}">更多 <i class="angle double down icon"></i></a>
                                </div>
                            </div>
                            <div class="ui teal segment" style="background-color: rgba(255, 255, 255, 0) !important;">
                                <a href="" th:href="@{/tags/{id}(id=${tag.id})}" th:each="tag : ${tags}" class="ui teal basic left pointing label m-margin-tb-tiny">
                                    <span th:text="${tag.name}">MySQL</span> <div class="detail" th:text="${#arrays.length(tag.blogList)}">23</div>
                                </a>
                            </div>
                        </div>
                    </div>
                    <!--阅读排行榜-->
                    <div class="ui segments m-margin-tb-big">
                        <div class="ui secondary segment">
                            <div class="ui two column grid">
                                <div class="column">
                                    <i class="sort amount up icon"></i> 阅读排行榜
                                </div>
                                <div class="right aligned column">
                                    <a href="" th:href="@{/archives}">更多 <i class="angle double down icon"></i></a>
                                </div>
                            </div>
                            <div class="ui teal segment" style="background-color: rgba(255, 255, 255, 0) !important;">
                                <div class="ui fluid vertical menu" style="background-color: rgba(255, 255, 255, 0) !important;">
                                    <a href="" th:href="@{/blog/{id}(id=${blog.id})}" th:each="blog : ${blogTop}" class="item">
                                        <span  th:text="${blog.title}"> MySQL(一)</span>
                                        <div class="ui teal basic left pointing label"><i class="eye icon"></i><span th:text="${blog.views}">10</span> </div>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--默认隐藏，向下滚动时显现-->
    <div id="toolbar" class="m-padded m-fixed m-right-bottom" style="display: none;">
        <div class="ui vertical icon buttons">
            <button type="button" class="ui toc teal button">目录</button>
            <a href="#comment-container" class="ui teal button">留言</a>
            <button class="ui wechat icon button"><i class="weixin icon"></i></button>
            <button id="toTop-button" class="ui teal icon button"><i class="chevron up icon"></i></button>
        </div>
    </div>

    <!--显示的目录-->
    <div class="ui toc-container flowing popup transition hidden" style="width: 250px ;">
        <ol class="js-toc"></ol>
    </div>

    <!--微信二维码-->
    <div id="qrcode" class="ui wechat-qr flowing popup transition hidden">
        <!--<img src="./images/wechat.jpg" alt="" class="ui rounded image" style="width: 120px">-->
    </div>

    <!--底部栏-->
    <footer th:replace="_fragments :: footer" class="ui inverted vertical m-padded-tb-massive">
        <div class="ui center aligned container">
            <div class="ui inverted divided stackable grid">
                <div class="four wide column">
                    <img src="../static/images/wechat.jpg" alt="" style="width: 100px;">
                </div>
                <div class="four wide column">
                    <h4 class="ui inverted header m-text-spaced m-text-thin">最新博客</h4>
                    <div class="ui inverted link list">
                        <a href="" class="item">Java（User Story）</a>
                        <a href="" class="item">Linux（User Story）</a>
                        <a href="" class="item">Redis（User Story）</a>
                    </div>
                </div>
                <div class="four wide column">
                    <h4 class="ui inverted header m-text-spaced m-text-thin">联系我</h4>
                    <div class="ui inverted link list">
                        <a href="" class="item">邮箱：XX181028@163.com</a>
                        <a href="" class="item">QQ：1412265423</a>
                    </div>
                </div>
                <div class="four wide column">
                    <h4 class="ui inverted header m-text-spaced m-text-thin">LENSTAR</h4>
                    <p class="m-text-spaced m-text-thin m-opacity-mini" style="color: gainsboro">
                        这是我的个人博客，会分享我所学到的任何知识，希望和大家一起共同进步.....
                    </p>
                </div>
            </div>
            <div class="ui inverted section divider"></div>
            <p class="m-text-spaced m-text-thin m-opacity-mini" style="color: gainsboro">
                Copyright © 2020-2021 LENSTAR Designed by LENSTAR
            </p>
        </div>
    </footer>

<!--/*/<th:block th:replace="_fragments :: script">/*/-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<script src="../static/lib/prism/prism.js"></script>
<script src="../static/lib/tocbot/tocbot.min.js"></script>
<script src="../static/lib/qrcode/qrcode.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/jquery.scrollto@2.1.2/jquery.scrollTo.min.js"></script>
<script src="../static/lib/waypoints/jquery.waypoints.min.js"></script>
<!--/*/</th:block>/*/-->

    <script th:inline="javascript">
        // 点击按钮触发事件
        $('.menu.toggle').click(function () {
            $('.m-item').toggleClass('m-mobile-hide');
        });

        //显示支付二维码
        $('#payButton').popup({
            popup: $('.payRQ.popup'),
            on: 'hover',
            position: 'bottom center'
        });

        //显示目录
        $('.toc.button').popup({
            popup: $('.toc-container.popup'),
            on: 'click',
            position: 'left center'
        });

        //生成目录
        tocbot.init({
            // Where to render the table of contents.
            tocSelector: '.js-toc',
            // Where to grab the headings to build the table of contents.
            contentSelector: '.js-toc-content',
            // Which headings to grab inside of the contentSelector element.
            headingSelector: 'h1, h2, h3'
        });

        // 显示微信
        $('.wechat').popup({
            popup: $('.wechat-qr'),
            position: 'left center'
        });

        var serurl = /*[[#{blog.serurl}]]*/"127.0.0.1:8080";
        var url = /*[[@{/blog/{id}(id=${blog.id})}]]*/"";
        //二维码生成
        var qrcode = new QRCode("qrcode", {
            text: serurl + url,
            width: 110,
            height: 110,
            colorDark : "#000000",
            colorLight : "#ffffff",
            correctLevel : QRCode.CorrectLevel.H
        });

        //平滑滚动
        $('#toTop-button').click(function () {
           $(window).scrollTo(0,500);
        });

        //滚动侦测
        var waypoint = new Waypoint({
            element: document.getElementById('container'),
            handler: function(direction) {
                // console.log('Scrolled to waypoint!' + direction)//direction滚动的方向（up down）
                if (direction == 'down') {
                    $('#toolbar').show(500);
                } else {
                    $('#toolbar').hide(500);
                }
            }
        });

        //评论表单验证
        $('.ui.form').form({
            fields: {
                title: {
                    identifier: 'content',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入评论内容'
                    }
                    ]
                },
                content: {
                    identifier: 'nickname',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入你的大名'
                    }]
                },
                type: {
                    identifier: 'email',
                    rules: [{
                        type: 'email',
                        prompt: '请填写正确的邮箱地址'
                    }]
                }
            }
        });

        $(function () {
            $("#comment-container").load(/*[[@{/comments/{id}(id=${blog.id})}]]*/"comments/6");
        });

        $('#commentpost-btn').click(function () {
            var boo = $('.ui.form').form('validate form');
            if (boo) {
                console.log('校验成功');
                postData();
            } else {
                console.log('校验失败');
            }
        });

        function postData() {
            $("#comment-container").load(/*[[@{/comments}]]*/"",{
                "parentComment.id" : $("[name='parentComment.id']").val(),
                "blogId" : $("[name='blogId']").val(),
                "nickname": $("[name='nickname']").val(),
                "email"   : $("[name='email']").val(),
                "content" : $("[name='content']").val()
            },function (responseTxt, statusTxt, xhr) {
                $(window).scrollTo($('#goto'),500);
                clearContent();
            });
        }

        function clearContent() {
            $("[name='nickname']").val('');
            $("[name='email']").val('');
            $("[name='content']").val('');
            $("[name='parentComment.id']").val(-1);
            $("[name='content']").attr("placeholder", "请输入评论信息...");
        }

        function reply(obj) {
            var commentId = $(obj).data('commentid');
            var commentNickname = $(obj).data('commentnickname');
            $("[name='content']").attr("placeholder", "@"+commentNickname).focus();
            $("[name='parentComment.id']").val(commentId);
            $(window).scrollTo($('#comment-form'),500);
        }

        // 最新博客
        function newBlog() {
            $.get({
                url:/*[[@{/newBlog}]]*/"/newBlog",
                success:function (data) {
                    //这里的data是后台传来的数据
                    document.getElementById("newBlog-1").innerText = data[0].title;
                    document.getElementById("newBlog-2").innerText = data[1].title;
                    document.getElementById("newBlog-3").innerText = data[2].title;
                    document.getElementById("newBlog-1").href = "/blog/"+data[0].id;
                    document.getElementById("newBlog-2").href = "/blog/"+data[1].id;
                    document.getElementById("newBlog-3").href = "/blog/"+data[2].id;
                }
            });
        }
        newBlog();
    </script>
</body>
</html>
